package com.summerlabs.nfc.utils

import android.content.Context
import android.widget.Toast
import com.summerlabs.nfc.App

object ToastUtils {
    private var toast: Toast? = null
    private val context: Context
         get() = App.context

    fun showShort(resId: Int) {
        if (toast != null) {
            toast!!.cancel()
            toast = null
        }
        toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT)
        toast?.show()
    }

    fun showShort(msg: String?) {
        if (toast != null) {
            toast!!.cancel()
            toast = null
        }
        toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT)
        toast?.show()
    }

    fun showLong(resId: Int) {
        if (toast != null) {
            toast!!.cancel()
            toast = null
        }
        toast = Toast.makeText(context, resId, Toast.LENGTH_LONG)
        toast?.show()
    }

    fun showLong(msg: String?) {
        if (toast != null) {
            toast!!.cancel()
            toast = null
        }
        toast = Toast.makeText(context, msg, Toast.LENGTH_LONG)
        toast?.show()
    }
}